/**
 * 
 */
package com.eascs.crm.nsEditDetail.service.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.eascs.crm.nsEditDetail.dao.MainShopInfoDao;
import com.eascs.crm.nsEditDetail.entity.O2oMainShopInfoEntity;
import com.eascs.crm.nsEditDetail.service.IMainShopInfoService;

/**@Description:
 *               <p>
 *               实现经营主体门店信息接口
 *               </p>
 * @author LMX
 */
@Service
public class MainShopInfoServiceImpl implements IMainShopInfoService{

	@Autowired
	MainShopInfoDao mainShopInfoDao;

	/**
	 * @Description:
	 *               <p>
	 *               根据主体门店id查询实体
	 *               </p>
	 * @author LMX
	 */
	@Override
	public O2oMainShopInfoEntity getEntityById(String id) {
		return mainShopInfoDao.getById(O2oMainShopInfoEntity.class, id);
	}

	/**
	 * @Description:
	 *               <p>
	 *                保存修改经营主体信息
	 *               </p>
	 * @author LMX
	 */
	@Override
	public boolean update(O2oMainShopInfoEntity info) {
		return mainShopInfoDao.updateById(info) > 0;
	}

	/**
	 * @Description:
	 *               <p>
	 *                新增经营主体信息
	 *               </p>
	 * @author LMX
	 */
	@Override
	public boolean insert(O2oMainShopInfoEntity info) {
		return mainShopInfoDao.insert(info) > 0;
	}

	/**@Description:
	 *               <p>
	 *               根据loanapplyNo查询经营主体信息
	 *               </p>
	 * @author LMX
	 */
	@Override
	public O2oMainShopInfoEntity getByLoanNo(String loanapplyNo) {
		String sql = "SELECT * from o2o_main_shop_info t where t.loanapply_no = ?";
		return mainShopInfoDao.findEntity(sql, O2oMainShopInfoEntity.class, loanapplyNo);
	}
	
	/**
	 * @Description:
	 *               <p>
	 *               根据loanapplyNo查询经营主体信息 脱敏
	 *               </p>
	 * @author LMX
	 * @date 2018年3月6日 下午4:30:08
	 */
	@Override
	public O2oMainShopInfoEntity getByLoanNo_sensitive(String loanapplyNo) {
		String sql = "SELECT CONCAT(LEFT(t.licence_name, 6), '******') AS licence_name, CONCAT(LEFT(t.blr_number, 3),'****',RIGHT(t.blr_number, 3)) AS blr_number from o2o_main_shop_info t where t.loanapply_no = ?";
		return mainShopInfoDao.findEntity(sql, O2oMainShopInfoEntity.class, loanapplyNo);
	}

}
